<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    {block name="title"}<title>CBOX短视频</title>{/block}
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 微软雅黑;
        }

        li {
            list-style: none;
        }

        a {
            text-decoration: none;
        }

        /*头部*/
        .ogg {
            width: 100%;
            background-color: #000;
            height: 3rem;
            position: fixed;
            z-index: 9999;
        }

        .adnnx {
            position: absolute;
            z-index: 3;
            left: .5rem;
            top: .5rem;
            height: 2rem;
        }

        .imgsx {
            height: 2rem;
        }

        .jhfs {
            width: 13rem;
            height: 3rem;
            margin-left: 6rem;
        }

        .imgsd {
            width: 90%;
            height: 80%;
            margin: 5px auto;
        }

        .adnnx3 {
            position: absolute;
            top: .85rem;
            right: .5rem;
            height: 1.25rem;
            line-height: 1.25rem;
            padding: 0 1.1rem;
            font-size: .75rem;
            z-index: 7;
            border-radius: 1rem;
            color: #fff;
            background-color: #fd4c5e;
        }

        /*头部导航*/
        .list {
            overflow: hidden;
            position: fixed;
            background: #fff;
            z-index: 9999;
            width: 100%;
            height: 2.75rem;
        }

        .list li {
            float: left;
            width: 14.5%;
            font-weight: 700;
            background-color: #fff;
            text-align: center;
            line-height: 2.45rem;
        }

        .list span {
            font-size: 0.98rem;
            height: 2.3rem;
            display: block;
        }

        .btn_find {
            background: url() center no-repeat;
            background-size: 50%;
            float: left;
            height: 2.3rem;
            width: 10%;
            margin-left: 1%;
            margin-top: 1px;
        }

        .active {
            color: rgb(253, 76, 93);
        }

        .line {
            background: url() bottom center no-repeat;
            background-size: 25% 2px;
        }

        /*播放器*/
        .li_ul {
            padding-top: 2.75rem;
            padding-bottom: 2.7rem;
            /*display: none;*/
        }

        .vodm1 {
            width: 100%;
            height: auto;
            position: relative;
            overflow: hidden;
            border-bottom: 0.43rem solid #eee;
        }

        .imgh {
            width: 100%;
            height: 13.2rem;
            position: relative;
            text-align: center;
        }

        .imgh .imgh1 {
            width: 100%;
            height: 100%;
            z-index: 0;
            position: relative;
        }

        .imgh .imgh2 {
            width: 2.94rem;
            height: 2.94rem;
            top: 50%;
            left: 50%;
            margin-left: -1.47rem;
            margin-top: -1.47rem;
            z-index: 999;
            position: absolute;
        }

        .vodm1 .duration {
            background-color: rgba(0, 0, 0, .5);
            width: 43px;
            height: 18px;
            line-height: 18px;
            bottom: 8px;
            right: 8px;
            z-index: 999;
            position: absolute;
            border-radius: .6rem;
            color: #fff;
            font-size: 12px;
        }

        .toptitle {
            height: 4.5rem;
            z-index: 2;
            width: 100%;
            position: absolute;
            top: 0;
            background: url() no-repeat center;
            background-size: cover;
        }

        .toptitle span {
            width: 90%;
            display: inline-block;
            color: #fff;
            padding: .5rem 0 0 .5rem;
            font-size: 26px;
        }

        .divl {
            color: #999;
            height: 2.65rem;
            display: inline-block;
            font-size: 0.85rem;
        }

        .divl img {
            width: 100%;
        }

        .idk {
            float: left;
            margin-left: .85rem;
            width: 3.8rem;
            background-color: #f5f7f9;
            border-radius: 0.7rem;
            height: 1.5rem;
            margin-top: .6rem;
        }

        .idk img {
            width: 1.5rem;
            float: left;
        }

        .idk span {
            float: left;
            font-size: 0.85rem;
            line-height: 1.5rem;
        }

        .play {
            float: right;
            width: 1.2rem;
            margin-right: 2.35rem;
            font-size: 0.85rem;
            color: #666;
            line-height: 2.85rem;
        }

        .look {
            float: right;
            width: 1.2rem;
            margin-right: .5rem;
        }

        .look img {
            vertical-align: middle;
        }

        .li_last {
            color: #999;
            text-align: center;
            padding: 5px 0 35px 0;
        }

        #video-container {
            display: none;
            position: absolute;
            left: 0;
            top: 0;
            padding-top: 5.74rem;
            width: 100%;
            height: 13.2rem;
        }

        #video-container video {
            width:100%;
            height:100%;
            object-fit: fill;
        }

        /*底部导航栏*/
        .pcx {
            width: 100%;
            height: 49px;
            position: fixed;
            background-color: #fff;
            bottom: 0;
            font-size: 0.653rem;
            z-index: 9999;
            border-top: 1px solid #ddd;
            color: #000;
        }

        .oix {
            width: 43%;
            position: absolute;
            height: 49px;
        }

        .bl {
            left: 0;
            top: 0;
        }

        .bc {
            left: 43%;
            bottom: .3rem;
            text-align: center;
            position: absolute;
            width: 14%;
        }

        .br {
            right: 0;
            top: 0;
        }

        .zw {
            width: 0.98rem;
            margin: 0 auto;
            margin-top: 10px;
        }

        .iconz {
            width: 16px;
            height: 16px;
        }

        .wentxt {
            text-align: center;
            font-weight: 700;
            color: #000;
        }

        .wentxt.active {
            color: #FD4C5D;
        }

        .iconv {
            width: 100%;
            height: 100%;
        }

        /*弹出层*/
        .bvsd {
            width: 100vw;
            height: 100vh;
            background-color: rgba(0, 0, 0, 0.7);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 99999999;
            display: none;
        }

        .ops {
            width: 17rem;
            height: 12rem;
            background-color: #fff;
            border-radius: 1rem;
            margin: auto;
            position: absolute;
            left: 0;
            right: 0;
            top: 25%;
        }

        .yupw {
            position: absolute;
            width: 1rem;
            height: 1rem;
            right: .75rem;
            top: .75rem;
        }

        .qr .ops {
            background-color: initial;
            width: 15rem;
            height: 15rem;
        }

        .qr .yupw {
            width: 2rem;
            height: 2rem;
            right: -1.5rem;
            top: -0.75rem;
            z-index: 99;
        }

        .qr .img_qr {
            width: 15rem;
            height: 15rem;
        }

        .vodm1 .imgh {
            background-size: cover;
        }
    </style>
    {block name="css"}
        <!--css-->
    {/block}
</head>
<body>
{block name="main"}
    <!--主体-->
{/block}

<!--隐藏的播放器-->
<div id="video-container">
    <video controls="controls" controlslist="nodownload" poster="/public/static/img/1.png">
        <source type="video/mp4" src="">
    </video>
</div>
<script src="__JS__/jquery.min.js"></script>
{block name="js"}
    <!--js-->
{/block}
<script>
    //播放视频
    var old_pic;
    function open_play(obj) {
        $('.imgh2').show();
        $('.toptitle').show();
        $(obj).find('.imgh2').hide();
        $(obj).siblings('.toptitle').hide();

        var top = $(obj).parent().parent().position().top;
        $("#video-container").css('top', parseInt(top) - 91.828125).show();

        if (player.src != "") {
            var current_vid = $(obj).attr('fileId');
            video_stats(current_vid);
        }

        player.src = $(obj).attr("url");
        player.play();

        video_top = $(obj).offset().top;

        //还原视频封面

        /*
        if(old_pic){
            $(".open_play .imgh1").attr('src', old_pic);
        }

        //如果是付费视频 则添加暂停付费标记
        if($(obj).attr("isfree") == 1){
            $('.li_ul li').removeClass('open_play');
            $(obj).parent().parent().addClass('open_play');
        }*/
    }

    player.addEventListener('pause', function () {
        var open_play = $('.open_play');

        //非付费视频退出长按
        if(open_play.length == 0) {
            return;
        }

        //暂停隐藏播放器
        $('#video-container').hide();
        player.pause();

        //更换为付费封面并保存视频封面
        old_pic = open_play.find('.imgh').css("backgroundImage").replace('url("','').replace('")','');
        open_play.find('.imgh').css("background-image","url(__H5__/pause_free.jpg)" );

        //监听封面长按事件
        $(".open_play .imgh").on({
            touchstart: function(e){
                longClick = 0;
                timeOutEvent = setTimeout(function(){
                    longClick = 1;
                    //跳转到支付页面
                    location.href = "/h5_pay_ok?fileId=" + $(".open_play .imgh").attr('fileid');
                },500);
            },
            touchmove: function(){
                clearTimeout(timeOutEvent);
                timeOutEvent = 0;
                e.preventDefault();
            },
            touchend: function(e){
                clearTimeout(timeOutEvent);
                if(timeOutEvent!=0 && longClick==0){ //不是长按则恢复播放
                    player.play();
                    $('#video-container').show();
                }
                return false;
            }
        });
    });

    //时间转换
    function s_to_hs(s) {
        var h;
        h = Math.floor(s / 60);
        s = s % 60;
        h += '';
        s += '';
        h = (h.length == 1) ? '0' + h : h;
        s = (s.length == 1) ? '0' + s : s;
        return h + ':' + s;
    }

    //随机排序
    function shuffle(arr1) {
        arr1.sort(function () {
            return Math.random() - 0.5;
        });
    }

    //视频统计
    function video_stats(current_vid) {
        console.log("视频统计");
        $.ajax({
            url: '/video_stats_index',
            type: "POST",
            dataType: "json",
            xhrFields: {withCredentials: true},
            data: {
                'currentTime': player.currentTime,
                'current_vid': current_vid,
                'type': "inline",
                'channel': 11,
                'exp': (player.currentTime / player.duration > 0.7) ? 1 : 0
            },
            success: function (res) {
                console.log(res);
            }
        });
    }
</script>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?7741d4cbd941d985eb296c908ef40bf2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</body>
</html>